﻿@{
    ViewBag.Title = "ContactUs";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section FooterScripts
{
    <script type="text/javascript">
        $(document).ready(function () {
            //wire up to the form submit event
            $("#tenantForm, #landlordForm").submit(function (event) {
                event.preventDefault(); //prevent the actual form post
                AjaxCallHelper(this, OnAjaxCallSuccess, "html");
            });
        });

        function AjaxCallHelper(form, callback, format) {
            $.ajax({
                url: form.action,
                type: form.method,
                dataType: format,
                data: $(form).serialize(),
                completed: null,
                success: callback
            });
        }

        function OnAjaxCallSuccess(result) {
            if (result) {
                alert("发送成功");
            }
            else {
                alert("发送失败，请重试");
            }
            $("#btnTenant").attr("onclick", "SendEmailButtonClick('#tenantForm');");
            $("#btnLandlord").attr("onclick", "SendEmailButtonClick('#landlordForm');");
            $("#btnTenant, #btnLandlord").removeClass("newGrayButton").addClass("newBlueButton");
            $("#tenantLoadingImg,#landlordLoadingImg").css("display", "none");
        }

        function SendEmailButtonClick(formID) {
            if (!CheckValidation(formID))
                return;
            if (formID == "#tenantForm") {
                $("#tenantLoadingImg").css("display", "inline-block");
            }
            else {
                $("#landlordLoadingImg").css("display", "inline-block");
            }
            $("#btnTenant, #btnLandlord").attr("onclick", null);
            $("#btnTenant, #btnLandlord").removeClass("newBlueButton").addClass("newGrayButton");
            $(formID).submit();
        }

        function CheckValidation(formID) {
            if (formID == "#tenantForm") {
                // name is required
                if ($("#tenantName").val() == "") {
                    $("#tenantName").css("border", "1px solid #ff2a00");
                    return false;
                }
                else {
                    $("#tenantName").css("border", "1px solid #abadb3");
                }

                // email is required
                if ($("#tenantEmail").val() == "") {
                    $("#tenantEmail").css("border", "1px solid #ff2a00");
                    return false;
                }
                else {
                    $("#tenantEmail").css("border", "1px solid #abadb3");
                }
            }
            else {
                if ($("#landlordName").val() == "") {
                    $("#landlordName").css("border","1px solid #ff2a00");
                    return false;
                }
                else {
                    $("#landlordName").css("border", "1px solid #abadb3");
                }

                // email is required
                if ($("#landlordEmail").val() == "") {
                    $("#landlordEmail").css("border", "1px solid #ff2a00");
                    return false;
                }
                else {
                    $("#landlordEmail").css("border", "1px solid #abadb3");
                }
            }
            return true;
        }
    </script>    
}

<div class="mainCenterContent">
    <div class="flagBid">
        <span>We are the Warm Family Builder! Be Professional! Be Happiness!</span>
    </div>

    <div class="divCompanyContent">
        <div id="divContact" class="left"> 
            <div class="header">
                <span>@SuZhouHouses.Resources.LanguageResources.IndexView.MenuBarContactus</span>
            </div>

            <div>
                <p>We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness!</p>
                <p>We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness!</p>
                <p>We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness! We are the Warm Family Builder! Be Professional! Be Happiness!</p>
            </div>
@using (Html.BeginForm("SendContactEmail", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "tenantForm" }))
{
            <div class="submitBox">
                <h5>I am tenant.</h5>
                <div>
                    <ul class="ulSubmitContentForm">
                        <li>
                            <div>Name:</div>
                            <input type="text" name="tbName" id="tenantName" />
                        </li>
                        <li>
                            <div>Phone:</div>
                            <input type="text" name="tbPhone" />
                        </li>
                        <li>
                            <div>Email:</div>
                            <input type="text" name="tbEmail" id="tenantEmail" />
                        </li>
                        <li>
                            <div>Subject:</div>
                            <input type="text" name="tbSubject"  />
                        </li>
                        <li>
                            <div>Content:</div>
                            <textarea name="tbContent"></textarea>
                        </li>
                    </ul>
                </div>

                <span id="btnTenant" class="newBlueButton" onclick="SendEmailButtonClick('#tenantForm');" style="height:34px; line-height:34px; padding:0px 29px; font-size:14px; margin-left:100px;">Send</span>
                <img src="../../Content/Images/Sprites/loading.gif" id="tenantLoadingImg" style="display:none;" />
                <div class="clearFloat"></div>
            </div>
            <input type="hidden" name="isTenant" value="true" />
}

@using (Html.BeginForm("SendContactEmail", "Home", FormMethod.Post, new { enctype = "multipart/form-data", id = "landlordForm" }))
{
            <div class="submitBox" style="margin-left:6px;">
                <h5>I am landlord.</h5>
                <div>
                    <ul class="ulSubmitContentForm">
                        <li>
                            <div>Name:</div>
                            <input type="text" name="tbName" id="landlordName" />
                        </li>
                        <li>
                            <div>Phone:</div>
                            <input type="text" name="tbPhone" />
                        </li>
                        <li>
                            <div>Email:</div>
                            <input type="text" name="tbEmail" id="landlordEmail" />
                        </li>
                        <li>
                            <div>Subject:</div>
                            <input type="text" name="tbSubject" />
                        </li>
                        <li>
                            <div>Content:</div>
                            <textarea name="tbContent"></textarea>
                        </li>
                    </ul>
                </div>

                <span id="btnLandlord" onclick="SendEmailButtonClick('#landlordForm');" class="newBlueButton" style="height:34px; line-height:34px; padding:0px 29px; font-size:14px; margin-left:100px;">Send</span>
                <img src="../../Content/Images/Sprites/loading.gif" id="landlordLoadingImg" style="display:none;" />
                <div class="clearFloat"></div>
            </div>
            <input type="hidden" name="isTenant" value="false" />
}
        </div>

        <div class="left housePic" style="margin-top:44px;">

        </div>

        <div class="contactInfo left">
            <ul id="ulContact">
                <li>地址：上海市闸北区延长中路576号A座1302室</li>
                <li>加盟电话：021-56777789</li>
                <li>传真：021-66374334</li>
                <li>电子邮件：xiaojiang@sina.com</li>
                <li>网址：<a href="#">http://www.xxxxx.com</a></li>
            </ul>
        </div>

        
        <div class="clearFloat" ></div>
    </div>
    
</div>

